#include "File.h"

std::string File::readString()
{
	unsigned int size = 0;
	char* buffer = NULL;
	std::string result;

	m_file.read((char*)&size,sizeof(unsigned int));

	buffer = new char [size + 1];

	for (unsigned int i = 0; i <= size; i++)
	{
		buffer[i] = '\0';
	}

	m_file.read(buffer, size);

	result = std::string(buffer);
	delete[] buffer;

	return result;
}

void File::saveString(std::string element)
{
	unsigned int size = (unsigned int)element.size();
	m_file.write((char*)&size, sizeof(unsigned int));
	m_file.write(element.c_str(), element.size());
}
